<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
	<title>jQuery Accordion</title>
	
	<link rel="stylesheet" href="accordion.css" />
	
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="chili-1.7.pack.js"></script>
	<script type="text/javascript" src="jquery.easing.js"></script>
	<script type="text/javascript" src="jquery.accordion.js"></script>

	<script type="text/javascript">
	jQuery().ready(function(){
		// simple Accordion
		jQuery('#list1').Accordion();
		
		// second simple Accordion with special markup
		jQuery('#navigation').Accordion({
			active: false,
			header: '.head',
			navigation: true,
			event: 'mouseover',
			autoheight: true,
			animated: 'easeslide'
		});
		
		// highly customized Accordion
		jQuery('#list2').Accordion({
			event: 'mouseover',
			active: '.selected',
			selectedClass: 'active',
			animated: "bounceslide"
		}).change(function(event, newHeader, oldHeader, newContent, oldContent) {
			jQuery('<div>' + oldHeader.text() + ' hidden, ' + newHeader.text() + ' shown</div>').appendTo('#log');
		});
		
		// first simple Accordion with special markup
		jQuery('#list3').Accordion({
			header: 'div.title',
			active: false,
			alwaysOpen: false,
			animated: false
		});
		
		var wizard = $("#wizard").Accordion({
			header: '.title',
			event: false
		});
		
		$("div.title", wizard).each(function(index) {
			$(this)
			.next()
			.children(":button")
			.filter(".next, .previous")
			.click(function() {
				wizard.activate(index + ($(this).is(".next") ? 1 : -1))
			});
		});
		
		// bind to change event of select to control first and seconds accordion
		// similar to tab's plugin triggerTab(), without an extra method
		jQuery('#switch select').change(function() {
			jQuery('#list1, #list2, #list3, #navigation').activate( this.selectedIndex-1 );
		});
		jQuery('#close').click(function() {
			jQuery('#list1, #list2, #list3, #navigation').activate(-1);
		});
		jQuery('#switch2').change(function() {
			jQuery('#list1, #list2, #list3, #navigation').activate(this.value);
		});
		
	});
	</script>

</head>
<body>

<h1 id="banner">jQuery Accordion Demo</h1>
<div id="main">

	<fieldset>
		<legend>Standard, container is a div, header is h3 and content p</legend>	

		<h3>Code</h3>
		<pre><code class="mix">jQuery('#list1').Accordion();</code></pre>

		<div id="list1">
			<h3>There is one obvious advantage:</h3>
			<div>
				<p>
					You've seen it coming!<br/>
					Buy now and get nothing for free!<br/>
					Well, at least no free beer. Perhaps a bear, if you can afford it.
				</p>
			</div>
			<h3>Now that you've got...</h3>
			<div>
				<p>
					your bear, you have to admit it!<br/>
					No, we aren't selling bears.
				</p>
				<p>
					We could talk about renting one.
				</p>
			</div>
			<h3>Rent one bear, ...</h3>
			<div>
				<p>
					get two for three beer.
				</p>
				<p>
					And now, for something completely different.
				</p>
			</div>
		</div>
		
	</fieldset>
		
	<fieldset>
		<legend>Navigation - Unordered List with anchors and nested lists.</legend>
		<p>Location-based state-saving: The active element is choosen based on location.hash: Click one of the links, then reload the page to see it in action.</p>

		<h3>Code</h3>
		<pre><code class="mix">jQuery('#navigation').Accordion({
	active: false,
	header: '.head',
	navigation: true,
	event: 'mouseover',
	autoheight: true,
	animated: 'easeslide'
});</code></pre>

		<ul id="navigation">
			<li>
				<a class="head" href="?p=1.1.1">Guitar</a>
				<ul>
					<li><a href="?p=1.1.1.1">Electric</a></li>
					<li><a href="?p=1.1.1.2">Acoustic</a></li>
					<li><a href="?p=1.1.1.3">Amps</a></li>
					<li><a href="?p=1.1.1.4.1">Effects A</a></li>
					<li><a href="?p=1.1.1.4.2">Effects B</a></li>
					<li><a href="?p=1.1.1.4.3">Effects C</a></li>
					<li><a href="?p=1.1.1.4.4">Effects D</a></li>
					<li><a href="?p=1.1.1.5">Accessories</a></li>
				</ul> 
			</li>
			<li>
				<a class="head" href="?p=1.1.2">Bass</a>
				<ul>
					<li><a href="?p=1.1.2.1">Electric</a></li>
					<li><a href="?p=1.1.2.2">Acoustic</a></li>
					<li><a href="?p=1.1.2.3">Amps</a></li>
					<li><a href="?p=1.1.2.4">Effects</a></li>
					<li><a href="?p=1.1.2.5">Accessories</a></li>
				</ul> 
			</li>
			<li>
				<a class="head" href="?p=1.1.3">Drums</a>
				<ul>
					<li><a href="?p=1.1.3.2">Acoustic Drums</a></li>
					<li><a href="?p=1.1.3.3">Electronic Drums</a></li>
					<li><a href="?p=1.1.3.4">Cymbals</a></li>
					<li><a href="?p=1.1.3.5">Hardware</a></li>
					<li><a href="?p=1.1.3.6">Accessories</a></li>
				</ul> 
			</li>
		</ul>
		
	</fieldset>

	<fieldset>
		<legend>With options, container is a definition list, header dt, content dd</legend>
		
		<h3>Code</h3>
		<pre><code class="mix">// highly customized Accordion
jQuery('#list2').Accordion({
	event: 'mouseover',
	active: '.selected',
	selectedClass: 'active',
	animated: "bounceslide"
}).change(function(event, newHeader, oldHeader, newContent, oldContent) {
	jQuery('&lt;div&gt;' + oldHeader.text() + ' hidden, ' + newHeader.text() + ' shown&lt;/div&gt;').appendTo('#log');
});</code></pre>

		<dl id="list2">
			<dt class="red">Red</dt>
			<dd>
				Fancy stuff about red thingies.
			</dd>
			<dt class="green selected">Green</dt>
			<dd>
				Green! Green! Green!
			</dd>
			<dt class="blue">Blue</dt>
			<dd>
				Cool kids are blue.
			</dd>
		</dl>
		
	</fieldset>

	<fieldset>
		<legend>Divitus structure, div container, div header (class title), div
		content, no active on startup and can be completely closed</legend>
		
		<h3>Code</h3>
		<pre><code class="mix">jQuery('#list3').Accordion({
		header: 'div.title',
		active: false,
		alwaysOpen: false,
		animated: false
	});</code></pre>

		<div id="list3">
			<div>
				<div class="title">Tennis</div>
				<div>
					One ball, two players. Lots of fun.
				</div>
			</div>
			<div>
				<div class="title">Soccer</div>
				<div>
					One ball, 22 players. Lots of fun.
				</div>
			</div>
			<div>
				<div class="title">Baseball</div>
				<div>
					Well, one ball, some guys running around, some guys hitting others with a stick.<br/>
					Sounds like fun, doesn't it?
				</div>
				<div>
					Well, apart from the running part.
				</div>
			</div>
		</div>
		
	</fieldset>
	
	<fieldset>
		<legend>Accordion wizard</legend>
		
		<h3>Code</h3>
		<pre><code class="mix">var wizard = $("#wizard").Accordion({
	header: '.title',
	event: false
});

$("div.title", wizard).each(function(index) {
	$(this)
	.next()
	.children(":button")
	.filter(".next, .previous")
	.click(function() {
		wizard.activate(index + ($(this).is(".next") ? 1 : -1))
	});
});</code></pre>
	
		<div id="wizard">
			<div>
				<div class="title">Header 1</div>
				<div>
					Content 1<br/>
					<input type="button" class="next" value="next" />
				</div>
			</div>
			<div>
		
				<div class="title">Header 2</div>
				<div>
					Content 2<br/>
					<input type="button" class="previous" value="previous"/>
					<input type="button" class="next" value="next"/>
				</div>
			</div>
			<div>
				<div class="title">Header 3</div>
		
				<div>
					Content 3<br/>
					<input type="button" class="previous" value="previous"/>
				</div>
			</div>
		
		
		</div>
		
	</fieldset>
	
	<div id="switch">
		<select>
			<option>Switch to...</option>
			<option value="1">1</option>
			<option value="2">2</option>
			<option value="3">3</option>
		</select>
		<button id="close">Close all</button>
		Activate via selector, eg. ':first' or ':eq(1)': <input id="switch2" />
	</div>

	<div id="log"><div><strong>Log of the 2nd accordion</strong></div></div>
</div>
	</body>
</html>